package com.ruoyi.develop.payApplyBuyDetail.service.impl;

import java.util.List;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.DateUtils;
        import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.ruoyi.develop.payApplyBuyDetail.mapper.PayApplyBuyDetailMapper;
import com.ruoyi.develop.payApplyBuyDetail.domain.PayApplyBuyDetail;
import com.ruoyi.develop.payApplyBuyDetail.service.IPayApplyBuyDetailService;

/**
 * 采购单付款申请明细Service业务层处理
 * @author qh
 * @date 2025-03-22
 */
@Service
public class PayApplyBuyDetailServiceImpl implements IPayApplyBuyDetailService {
    @Resource
    private PayApplyBuyDetailMapper payApplyBuyDetailMapper;

    /**
     * 查询采购单付款申请明细
     * @param id 采购单付款申请明细主键
     * @return 采购单付款申请明细
     */
    @Override
    public PayApplyBuyDetail selectById(String id) {
        return payApplyBuyDetailMapper.selectById(id);
    }

    /**
     * 查询采购单付款申请明细列表
     * @param entity 采购单付款申请明细
     * @return 采购单付款申请明细
     */
    @Override
    public List<PayApplyBuyDetail> selectList(PayApplyBuyDetail entity) {
        return payApplyBuyDetailMapper.selectList(entity);
    }

    /**
     * 查询采购单付款申请明细列表
     * @param entity 采购单付款申请明细
     * @return 采购单付款申请明细
     */
    @Override
    public List<PayApplyBuyDetail> listByPayRecord(PayApplyBuyDetail entity) {
        return payApplyBuyDetailMapper.listByPayRecord(entity);
    }


    /**
     * 新增采购单付款申请明细
     * @param entity 采购单付款申请明细
     * @return 结果
     */
    @Override
    public int insert(PayApplyBuyDetail entity) {
        if(StringUtils.isBlank(entity.getId())){
            entity.setId(IdUtils.fastSimpleUUID());
        }
                entity.setCreateBy(SecurityUtils.getUsername());
                entity.setCreateTime(DateUtils.getNowDate());
            return payApplyBuyDetailMapper.insert(entity);
    }

    /**
     * 修改采购单付款申请明细
     * @param entity 采购单付款申请明细
     * @return 结果
     */
    @Override
    public int update(PayApplyBuyDetail entity) {
                entity.setUpdateBy(SecurityUtils.getUsername());
                entity.setUpdateTime(DateUtils.getNowDate());
        return payApplyBuyDetailMapper.update(entity);
    }

    /**
     * 批量删除采购单付款申请明细
     * @param ids 需要删除的采购单付款申请明细主键
     * @return 结果
     */
    @Override
    public int deleteByIds(String[] ids) {
        return payApplyBuyDetailMapper.deleteByIds(ids);
    }

    /**
     * 删除采购单付款申请明细信息
     * @param id 采购单付款申请明细主键
     * @return 结果
     */
    @Override
    public int deleteById(String id) {
        return payApplyBuyDetailMapper.deleteById(id);
    }
}
